﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using CNRegex.Web.Base;
using CNRegex.Biz.BizAccess;
using System.Configuration;
using CNRegex.Enum;
using CNRegex.Entity;
using System.Text;
using CNRegex.Web.Models;
using CNRegex.Biz;

namespace CNRegex.Web.Controllers
{
	public class RegexTutorialController : BaseController
	{
		private static Guid RegexTutorialID = Guid.Parse(ConfigurationManager.AppSettings.Get(EnumAppSettings.RegexTutorialID.ToString()));
		private BizRegexTutorialCatalogContentComment bizRegexTutorialCatalogContentComment;
		public RegexTutorialController()
		{

		}
		//
		// GET: /RegexTutorial/

		public ActionResult Index(Guid? id, int? pageIndex)
		{
			ModelTutorialTemplate model = new ModelTutorialTemplate(RegexTutorialID, "RegexTutorial", "Tutorial");
			return View(model);
		}

		public ActionResult Tutorial(Guid id, int? pageIndex)
		{
			ModelTutorialTemplateTutorialContent model = new ModelTutorialTemplateTutorialContent(id, RegexTutorialID, "RegexTutorial", "Tutorial") { PageIndex = pageIndex, CommentActionName = "Comment", CommentControllerName = "RegexTutorial" };
			return View(model);
		}

		[HttpPost]
		[ValidateInput(false)]
		public ActionResult Comment(Guid? id,RegexTutorialCatalogContentComment model)
		{
			model.CommentDate = DateTime.Now;
			model.UserID = FrontContext.CurrentRegexUser.ID;
			bizRegexTutorialCatalogContentComment.Save(model);
			return RedirectToAction("Tutorial", new { id = id });
		}

		

	}
}
